package com.unisv.dj.util;

import com.unisv.dj.ServerService;



/**
 * 
 * @author fanzhen
 * @time 5:27:32 PM Oct 1, 2011
 * @email fanzhen.meng@gmail.com
 */
public class Command {
//	public static volatile byte[] command;
	public static void start() {
		final byte[] command = new byte[4];
		command[0] = 11;
		command[1] = 100;
		command[2] = 100;
		command[3] = 1;
		doCommand(command);
	}

	public static void stopShort() {
		final byte[] command = new byte[4];
		command[0] = 11;
		command[1] = 0;
		command[2] = 0;
		command[3] = 2;
		doCommand(command);
	}

	public static void stopLong() {
		final byte[] command = new byte[4];
		command[0] = 11;
		command[1] = 0;
		command[2] = 0;
		command[3] = 3;
		doCommand(command);
	}

	public static void changeSpeed(int speed1, int speed2) {
		final byte[] command = new byte[4];
		command[0] = 12;
		command[1] = (byte) speed1;
		command[2] = (byte) speed2;
		command[3] = 0;
		doCommand(command);
	}

	public static void buttonPress(int press) {
		final byte[] command = new byte[4];
		command[0] = 11;
		command[1] = 0;
		command[2] = 0;
		command[3] = (byte) press;
		doCommand(command);
	}

	public static void fetchData() {
		final byte[] command = new byte[4];
		command[0] = 10;
		command[1] = 0;
		command[2] = 0;
		command[3] = 0;
		doCommand(command);
	}

	public static void regHeartRate() {
		final byte[] command = new byte[4];
		command[0] = 10;
		command[1] = 2;
		command[2] = 1;
		command[3] = 0;
		doCommand(command);
	}

	public static void unregHeartRate() {
		final byte[] command = new byte[4];
		command[0] = 10;
		command[1] = 2;
		command[2] = 0;
		command[3] = 0;
		doCommand(command);
	}

	public static void initDj() {
		final byte[] command = new byte[4];
		command[0] = 10;
		command[1] = 1;
		command[2] = 0;
		command[3] = 0;
		doCommand(command);
	}
	public static void doCommand(byte[] command){
		ServerService.doCommand(command);
	}
}